//
//  DetailAdressTextView.swift
//  XiaoJingMallSwift
//
//  Created by beisheng03 on 2017/8/31.
//  Copyright © 2017年 beisheng. All rights reserved.
//

import UIKit

class DetailAdressTextView: UITextView {
    
    lazy var placeholder : UILabel = {
        let temp = UILabel()
        temp.text = "街道,楼牌号等"
        temp.textColor = UIColor.lightGray
        temp.font = UIFont.systemFont(ofSize: 15)
        temp.sizeToFit()
        temp.frame.origin.x = 5
        temp.frame.origin.y = 8
        return temp
    }()
    


    override func awakeFromNib() {
        
        super.awakeFromNib()
        
        addSubview(placeholder)
        
        NotificationCenter.default.addObserver(self, selector: #selector(textChange), name: NSNotification.Name.UITextViewTextDidChange, object: self)

    }
    
    
    deinit {
        
        NotificationCenter.default.removeObserver(self)
    }
    
    
    @objc func textChange(){
        
        placeholder.isHidden = hasText
        
        
    }

    
}
